//
//  LBTILiveCollectionTitleView.m
//  AFNetworking
//
//  Created by 刘文扬 on 2018/4/25.
//

#import "LBTILiveCollectionTitleView.h"
#import <Masonry.h>

@interface LBTILiveCollectionTitleView()

/** titleBackgroundView*/
@property(nonatomic,strong)UIView *titleBackgroundView;

@end

@implementation LBTILiveCollectionTitleView

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.titleBackgroundView.layer.cornerRadius = self.titleBackgroundView.bounds.size.height / 2;
    self.titleBackgroundView.layer.masksToBounds = YES;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview:self.titleBackgroundView];
        
        [self addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.leading.offset(30);
        }];
        
        [self.titleBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.titleLabel).insets(UIEdgeInsetsMake(-6, -10, -6, -10));
        }];
        
    }
    return self;
}

-(UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:12];
        label.textColor = [UIColor whiteColor];
        label.numberOfLines = 1;
        _titleLabel = label;
        
    }
    return _titleLabel;
}

-(UIView *)titleBackgroundView
{
    if (_titleBackgroundView == nil) {
        
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        _titleBackgroundView = view;
    }
    return _titleBackgroundView;
}

@end

